layui.use(['form','treeSelect','layer','upload','laydate','layedit','tableSelect'],function(){
    var form = layui.form
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery;
    var upload = layui.upload;
    var laydate = layui.laydate;
    var treeSelect= layui.treeSelect;//树形下拉框
    var imgURL="";//多图片上传的路径





    var produceDesc;


    //回显数据
    var request = GetRequest();
    $.get("/admin/product/getProduct?productId=" + request.id,function (data) {
        $("#produceId").val(data.produceId);
        $("#produceName").val(data.produceName);
        $("#supplier").val(data.supplier);
        $("#produceNo").val(data.produceNo);
        var date = new Date(data.supplyDate);
        laydate.render({
            elem: '#supplyDate'
            ,value: date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate()   //必须遵循format参数设定的格式  + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds()
        });
        $("#buyer").val(data.buyer);
        $("#buyNum").val(data.buyNum);
        $("#unit").val(data.unit);
        $("#price").val(data.price);
        $("#threshold").val(data.threshold);
        $("#produceBrief").val(data.produceBrief);
        $.ajax({

                url:"/admin/productUsed/totalUsed?productId="+data.produceId,
                type:'GET',
                async:false,
                success:function (data){
                    $("#remainNum").val(data);
                }
            });


        $.ajax({
            //根据parentId查对应类别，从而拿到父类结点的名称
            url: '/admin/storage/getStorage?StorageId='+data.storageId,
            type: 'GET',
            success: function (da) {
                if(da!=null) {
                    $("#storageName").val(da.name);
                    $("#storageId").val(da.storageId);
                }
            }})
    });





    //获取路径中的参数
    function GetRequest() {
        var url = location.search;         //获取url中"?"符后的字串
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            var strs = str.split("&");
            for (var i = 0; i < strs.length; i++) {
                theRequest[strs[i].split("=")[0]] = decodeURIComponent(strs[i].split("=")[1]);
            }
        }
        return theRequest;
    }


});